<?php
class caradverts extends CI_Controller{
	public function index(){
		//Get all CarAdverts - /caradverts  [GET]
	}
	
	public function caradvert($first = "", $second = ""){
		switch ($_SERVER['REQUEST_METHOD']){
			case "GET":
				switch($first){
					case "bycar":
						//Get adverts by car - /caradverts/caradvert/bycar/$idcar  [GET]
					break;
					
					default:
						switch($second){
							case "delete":
								//Delete caradvert - /caradverts/caradvert/$id/delete  [GET]
							break;
							
							case "":
								//Get advert by id - /caradverts/caradvert/$id  [GET]
							break;
						}
					break;
				}
			break;
			
			case "POST":
				if ($first == "" && $second == "")
				{
					$postData = $this->decoder->Decode();
					
					$carAdvert = $postData->caradvert;
					
					$this->load->model('advert_m');
					$this->advert_m->iduser = $carAdvert->advert->iduser;
					$this->advert_m->text = $carAdvert->advert->text;
					
					
					$this->load->library('caradvert');
					
					
					$this->load->model('caradvert_m');
					$this->caradvert_m->caryear = $carAdvert->caryear;
					$this->idcar = $carAdvert->idcar;
					
				}
			break;
		}
	}
}
?>